import Flutter
import Foundation

class RecordBoxWindows: NSObject {
    public var stackView = UIStackView()

    init(_ args: [String: Any?]) {
        super.init()
        stackView.axis = .vertical
        stackView.alignment = .fill
        stackView.distribution = .fillEqually
        stackView.spacing = 1
        let fontSize = args["fontSize"] as! Int
        let textView = UITextView()
        textView.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
        textView.isUserInteractionEnabled = false
        textView.backgroundColor = .black
        textView.textColor = .white
        let uiView = UIView()
        uiView.addSubview(textView)
        stackView.addArrangedSubview(uiView)
        textView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
            make.top.left.right.bottom.margins.equalToSuperview()
        }
        print("加载录音框")
    }

    public func handle(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) -> Bool {
        switch call.method {
            case "updateRecordBoxTime":
                print("updateTime== 更新录音时间")
                result(true)
                return true
            case "updateRecordState":
                print("updateTime== 更新录音状态")
                result(true)
                return true
            default:
                break
        }
        return false
    }

    public func close() {
        stackView.removeFromSuperview()
    }
}
